//
//  ZYNCollectionViewCellForSelection.m
//  VideoPic
//
//  Created by dllo on 16/3/23.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "ZYNCollectionViewCellForSelection.h"
#import "ZYNModelForHotSongs.h"
#import <YYWebImage.h>
#define WIDTH self.contentView.frame.size.width

@interface ZYNCollectionViewCellForSelection()
@property (nonatomic, strong) UIImageView *imageView;
@property (nonatomic, strong) UIImageView *imageForTing;
@property (nonatomic, strong) UILabel *labelForListenCount;
@property (nonatomic, strong) UILabel *labelOfContent;
@end
@implementation ZYNCollectionViewCellForSelection

#pragma mark - init
- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubViews];
    }
    return self;
}

#pragma mark - createSubViews
- (void)createSubViews {
    
    self.imageView = [[UIImageView alloc] init];
    [self.contentView addSubview:self.imageView];
    
    self.imageForTing = [[UIImageView alloc] init];
    [self.contentView addSubview:self.imageForTing];
    
    self.labelForListenCount = [[UILabel alloc] init];
    [self.contentView addSubview:self.labelForListenCount];
    
    self.labelOfContent = [[UILabel alloc] init];
    [self.contentView addSubview:self.labelOfContent];
    
}

#pragma mark - layout
- (void)layoutSubviews {
    [super layoutSubviews];
    
    self.imageView.frame = self.contentView.frame;
   
    self.imageForTing.frame = CGRectMake(WIDTH / 2 + 5, 5, WIDTH / 6, WIDTH / 6);
    self.imageForTing.image = [UIImage imageNamed:@"Ting"];
    
    self.labelForListenCount.frame = CGRectMake(WIDTH / 4 * 3, 0, WIDTH / 4, WIDTH / 4);
    
    self.labelOfContent.frame = CGRectMake(0, WIDTH, WIDTH, WIDTH / 3);

}

#pragma mark - deliverModel
- (void)passModel:(ZYNModelForHotSongs *)model {
    self.imageView.yy_imageURL = [NSURL URLWithString:model.picUrl];
    self.labelOfContent.text = model.name;
    self.labelOfContent.font = [UIFont systemFontOfSize:14];
    self.labelOfContent.numberOfLines = 0;
    CGFloat count = model.listenCount;

    self.labelForListenCount.text = [NSString stringWithFormat:@"%.f万", count / 10000];
    self.labelForListenCount.font = [UIFont systemFontOfSize:12];
    self.labelForListenCount.textColor = [UIColor whiteColor];
    
    
    
}


@end
